How to  Sort TotalItemSize Property of Get-MailboxStatistics

Hi I have this querry, but it seems that powershell only sorts the items by its number value. How can I sort TotalItemSize by its bytes

Get-Mailbox -Server server01.domain.com -IgnoreDefaultScope | Get-MailboxStatistics | Sort-Object TotalItemSize | FT DisplayName, TotalItemSize

User0                                            2.927 GB (3,142,540,900 bytes)
User1                                     2.954 GB (3,171,835,975 bytes)
User2                                              208.3 MB (218,466,864 bytes)
User3                                            209.1 MB (219,220,247 bytes)
User4                                              227.2 MB (238,197,431 bytes)
User5                                                230.4 MB (241,579,414 bytes)
User6                                            268.9 MB (281,926,061 bytes)
User7                                             27.72 MB (29,069,644 bytes)
User8                                             270.3 MB (283,465,688 bytes)
User9                                                    29.03 MB (30,444,448 bytes)
User10                                         295.6 MB (309,909,793 bytes)
User11                                                     3.003 GB (3,224,569,519 bytes)
User12                                           3.017 GB (3,238,978,160 bytes)

How can I do this in powershell?

August 23rd, 2013 12:16pm

Hi I am using the same cmdlet , it is working fine  .

[PS] C:\>Get-Mailbox -OrganizationalUnit myou|Get-MailboxStatistics |sort totalitemsize|ft displayname,totalitemsize -AutoSize

DisplayName TotalItemSize
----------- -------------
MyAdmin     1.004 KB (1,028 bytes)
user13      80.56 KB (82,494 bytes)
user12      80.57 KB (82,501 bytes)
user14      80.58 KB (82,511 bytes)
user11      85.31 KB (87,354 bytes)
user17      151.4 KB (154,987 bytes)
user16      151.4 KB (154,991 bytes)
user18      151.4 KB (154,996 bytes)
user19      151.8 KB (155,417 bytes)
user15      151.8 KB (155,479 bytes)
user20      154.4 KB (158,150 bytes)

Free Windows Admin Tool Kit Click here and download it now
August 23rd, 2013 1:16pm

try this:

get-mailboxstatistics -server mxmbx01 | select displayname, itemcount, @{expression = {$_.TotalItemSize.Value.ToMB()}; label="TotalItemSizeMB"}, lastloggedtime, database | sort totalitemsizeMB | ft  

August 23rd, 2013 1:28pm

Hi The TotalItemSize in Exchange 2010 Sp2 is String

PS C:\Users\sheen.lim> Get-MailboxStatistics -Identity sheen.lim | Get-Member


   TypeName: Deserialized.Microsoft.Exchange.Data.Mapi.MailboxStatistics

Name                    MemberType   Definition
----                    ----------   ----------
ToString                Method       string ToString(), string ToString(string format, System.IFormatProvider format...
PSComputerName          NoteProperty System.String PSComputerName=ph-cdo-caexch01.gbsorg.net
PSShowComputerName      NoteProperty System.Boolean PSShowComputerName=False
RunspaceId              NoteProperty System.Guid RunspaceId=74866dc9-b7ef-457c-92a4-7507b63b14d9
AssociatedItemCount     Property     System.UInt32 {get;set;}
Database                Property     System.String {get;set;}
DatabaseName            Property     System.String {get;set;}
DeletedItemCount        Property     System.UInt32 {get;set;}
DisconnectDate          Property      {get;set;}
DisconnectReason        Property      {get;set;}
DisplayName             Property     System.String {get;set;}
Identity                Property     System.String {get;set;}
IsArchiveMailbox        Property     System.Boolean {get;set;}
IsQuarantined           Property     System.Boolean {get;set;}
IsValid                 Property     System.Boolean {get;set;}
ItemCount               Property     System.UInt32 {get;set;}
LastLoggedOnUserAccount Property     System.String {get;set;}
LastLogoffTime          Property     System.DateTime {get;set;}
LastLogonTime           Property     System.DateTime {get;set;}
LegacyDN                Property     System.String {get;set;}
MailboxGuid             Property     System.Guid {get;set;}
MailboxTableIdentifier  Property     System.String {get;set;}
MapiIdentity            Property     System.String {get;set;}
MoveHistory             Property      {get;set;}
ObjectClass             Property     System.String {get;set;}
OriginatingServer       Property     System.String {get;set;}
ServerName              Property     System.String {get;set;}
StorageLimitStatus      Property     System.String {get;set;}
TotalDeletedItemSize    Property     System.String {get;set;}
TotalItemSize           Property     System.String {get;set;}

Free Windows Admin Tool Kit Click here and download it now
August 29th, 2013 11:25pm

and ?

when you use this below you will  get list of mailboxes with mailbox size in MB

get-mailboxstatistics -server mbxserver | select displayname, itemcount, @{expression = {$_.TotalItemSize.Value.ToMB()}; label="TotalItemSizeMB"}, database | sort totalitemsizeMB | ft  

August 30th, 2013 2:40pm

When I use this code, the TotalItemSizeMB does not contain anything.
Free Windows Admin Tool Kit Click here and download it now
September 1st, 2013 2:00am

Hi Sheen Lim,

Please try the command below:

Get-MailboxStatistics -server mbxserver | select DisplayName, ItemCount, @{Name='TotalItemSizeMB'; Expression={[String]::join(";",((Get-MailboxStatistics -Identity $_.Identity).TotalItemSize.value.toMb()))}}, Database | sort TotalitemSizeMB | ft 

Hope it helps.

Regards,

Rebecca

September 2nd, 2013 9:42am

Hi

What version and service pack level of Exchange are you running?

Steve

  • Proposed as answer by James Net Tuesday, July 01, 2014 8:42 PM
  • Unproposed as answer by James Net Tuesday, July 01, 2014 8:42 PM
Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2013 9:47am

Hi I have this querry, but it seems that powershell only sorts the items by its number value. How can I sort TotalItemSize by its bytes

Get-Mailbox -Server server01.domain.com -IgnoreDefaultScope | Get-MailboxStatistics | Sort-Object TotalItemSize | FT DisplayName, TotalItemSize

User0                                            2.927 GB (3,142,540,900 bytes)
User1                                     2.954 GB (3,171,835,975 bytes)
User2                                              208.3 MB (218,466,864 bytes)
User3                                            209.1 MB (219,220,247 bytes)
User4                                              227.2 MB (238,197,431 bytes)
User5                                                230.4 MB (241,579,414 bytes)
User6                                            268.9 MB (281,926,061 bytes)
User7                                             27.72 MB (29,069,644 bytes)
User8                                             270.3 MB (283,465,688 bytes)
User9                                                    29.03 MB (30,444,448 bytes)
User10                                         295.6 MB (309,909,793 bytes)
User11                                                     3.003 GB (3,224,569,519 bytes)
User12                                           3.017 GB (3,238,978,160 bytes)

How can I do this in powershell?

Has anyone found a working PowerShell script to accomplish this task, on Exchange 2013?  I have tried the various scripts that *used* to work on Exchange 2007, but none of them properly sort by TotalItemSize in Exchange 2013.

Thanks!

July 1st, 2014 8:41pm

Has anyone found a working PowerShell script to accomplish this task, on Exchange 2013?  I have tried the various scripts that *used* to work on Exchange 2007, but none of them properly sort by TotalItemSize in Exchange 2013.

Thanks!

Try this...

I've been able to get the requested data, but a Select-Object has to be used earlier in the pipeline to define the appropriate property.  If you want additional properties on the object, you'll have to add them into the Select-Object area

I omitted the Format-Table cmdlet as it destroys the object and prevents further manipulation

Get-Mailbox | Get-MailboxStatistics | Select-Object -Property DisplayName,Item,Count,TotalItemSize,@{Label="SizeInBytes";Expression={$_.TotalItemSize.Value.ToString().Split('(')[1].Split(' ')[0].Replace(',','').ToInt32($null)}} | Sort-Object -Property SizeInBytes -Descending



Free Windows Admin Tool Kit Click here and download it now
May 15th, 2015 9:57am

Has anyone found a working PowerShell script to accomplish this task, on Exchange 2013?  I have tried the various scripts that *used* to work on Exchange 2007, but none of them properly sort by TotalItemSize in Exchange 2013.

Thanks!

Try this...

I've been able to get the requested data, but a Select-Object has to be used earlier in the pipeline to define the appropriate property.  If you want additional properties on the object, you'll have to add them into the Select-Object area

I omitted the Format-Table cmdlet as it destroys the object and prevents further manipulation

Get-Mailbox | Get-MailboxStatistics | Select-Object -Property DisplayName,Item,Count,TotalItemSize,@{Label="SizeInBytes";Expression={$_.TotalItemSize.Value.ToString().Split('(')[1].Split(' ')[0].Replace(',','').ToInt32($null)}} | Sort-Object -Property SizeInBytes -Descending



May 15th, 2015 1:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics